<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>系统菜单管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../statics/layui/css/layui.css">
    <link rel="stylesheet" href="../../../statics/layui/font/font.css" media="all"/>

</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">

        <div class="layui-card-header">菜单管理</div>
        <div class="layui-card-body" style="padding: 15px;">
            <form class="layui-form" lay-filter="formData">
                <input type="hidden" name="menuId" id="menuId" class="formData"/>
                <div class="layui-form-item">
                    <label class="layui-form-label">单位类型:</label>
                    <div class="layui-input-block">
                        <select name="menuOrgType" id="menuOrgType" class="formData" lay-verify="isEmpty">
                            <option value="">直接选择或搜索</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">菜单类型:</label>
                    <div class="layui-input-block" id="typeList">
                        <select name="type" id="type" class="formData" lay-verify="isEmpty">
                            <option value="">直接选择或搜索</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">菜单名称:</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" id="name" lay-verify="isEmpty" placeholder="请输入菜单名称"
                               autocomplete="off" class="layui-input formData">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">上级菜单:</label>
                    <div class="layui-input-block">
                        <input type="hidden" name="parentId" autocomplete="off" id="parentId" value="" class="formData"/>
                        <input type="text" name="parentName" id="parentName" lay-verify="isEmpty"
                               placeholder="点击选择上级菜单" autocomplete="off" class="layui-input formData">
                    </div>
                </div>


                <div class="layui-form-item">
                    <label class="layui-form-label">菜单URL：</label>
                    <div class="layui-input-block">
                        <input type="text" name="url" id="url" placeholder="请输入菜单URL" autocomplete="off"
                               class="layui-input formData">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">排序号:</label>
                    <div class="layui-input-block">
                        <input type="text" name="orderNum" id="orderNum" lay-verify="number" placeholder="请输入排序号"
                               autocomplete="off" class="layui-input formData">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">权限标识:</label>
                    <div class="layui-input-block">
                        <input type="text" name="perms" id="perms" placeholder="请输入权限标识" autocomplete="off"
                               class="layui-input formData">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">菜单图标:</label>
                    <div class="layui-input-block">
                        <input type="text" name="icon" id="icon" placeholder="请输入菜单图标" autocomplete="off"
                               class="layui-input formData" value="&#xe613;">
                    </div>
                </div>
                <button class="layui-btn search" lay-submit id="submit" style="display: none;">提交</button>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript" src="../../../statics/layui/layui.js"></script>
<script src="/static/js/main.js"></script>
<!--<script type="text/javascript" src="../../../statics/js/sys/editMenu.js"  charset="utf-8"></script>-->
<script>
    layui.use(['treeSelect', 'form', 'layer', 'configure', 'configureCom', 'sessionFun'], function () {
        window.$ = layui.$;
        var layer = layui.layer;
        var form = layui.form;
        var configureCom = layui.configureCom;
        var configure = layui.configure;
        var sessionFun = layui.sessionFun;
        var treeSelect = layui.treeSelect;
        var listData = sessionFun.get(configure.SESSION_LIST_DATA);
        treeSelect.render({
            elem: '#parentName',
            headers: {
                'token': configureCom.token
            },
            data: baseApi + '/sys/menu/select',
            type: 'get',
            placeholder: '点击选择上级菜单',
            search: true,
            style: {
                folder: {
                    enable: false
                },
                line: {
                    enable: true
                }
            },
            click: function (d) {
            },
            // 加载完成后的回调函数
            success: function (d) {
                if (listData) {
                    listData.icon = decodeURIComponent(listData.icon);
                    form.val('formData', listData);
                    $("#tmpParentName").val(listData.parentName);
                    configureCom.selectDataFun(configure.COMPANY_TYPE_CODE,listData.menuOrgType, '#menuOrgType');
                    configureCom.selectDataFun(configure.MENU_TYPE_CODE, listData.type, '#type');
                }else{
                    configureCom.selectDataFun(configure.COMPANY_TYPE_CODE, '', '#menuOrgType');
                    configureCom.selectDataFun(configure.MENU_TYPE_CODE, '', '#type');
                }
                form.render();
            }
        });
        form.on('submit', function (data) {
            return false;
        });
    });
    function getData() {
        var data = {};
        if (!window.formVerifyFun()) {
            return false;
        }
        $('.formData').each(function (index, item) {
            var key = $(item).attr('name');
            if($(item).attr('name')=='icon' && !$(item).val()){
                data[key] = '&#xe613;';
            }else{
                data[key] = $(item).val();
            }
        });
        data.icon = encodeURIComponent(data.icon);
        return data;
    }
</script>
</body>
</html>
